package com.tidy.seed.util;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;

//获取当前环境
@Component
public class ProfileUtils {

    private static String activeProfile;

    @Value("${spring.profiles.active:default}")
    public void setActiveProfile(String profile) {
        ProfileUtils.activeProfile = profile;
    }

    public static boolean isDev() {
        return "dev".equalsIgnoreCase(activeProfile);
    }

    public static boolean isTest() {
        return "test".equalsIgnoreCase(activeProfile);
    }

    public static boolean isProd() {
        return "prod".equalsIgnoreCase(activeProfile);
    }

    public static String getActiveProfile() {
        return activeProfile;
    }
}
